<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="icon" th:href="@{/img/logo.ico}" href="../static/img/logo.ico" type="images/x-ico"/>

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="../static/css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}">
    <title>公告列表</title>
    <link rel="stylesheet" th:href="@{/fontawesome/css/font-awesome.min.css}"
          href="../../static/fontawesome/css/font-awesome.min.css">

    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,500;0,600;0,700;1,400&display=swap">

    <!-- Fontawesome CSS -->
    <link rel="stylesheet" href="../static/fontawesome/css/fontawesome.min.css"
          th:href="@{/fontawesome/css/fontawesome.min.css}">
    <link rel="stylesheet" href="../static/fontawesome/css/all.min.css" th:href="@{/fontawesome/css/all.min.css}">

    <!-- Main CSS -->
    <link rel="stylesheet" href="../static/css/back_index.css" th:href="@{/css/back_index.css}">
    <style type="text/css">
        table {
            table-layout: fixed;
        }

        td {
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
    </style>
</head>
<body>
<div class="main-wrapper">
    <div th:replace="commons/bar::#teachermenubar(activeUri1='公告列表')"></div>
    <div class="page-wrapper">
        <div class="content container-fluid">
            <h2 align="center">公 告</h2>
            <div class="container">
                <div class="row" id="notice-datas">
                    <div class="card col-lg-4 col-md-6" id="notice-card">
                        <div class="card-body">
                            <h3 align="center" id="level" class="card-title"></h3>
                            <p class="card-text" id="noticeinfo"></p>
                        </div>
                    </div>
                </div>
            </div>
            <footer>
                <p>2020 &copy; 软件学院学生信息管理系统 by 郑焙元</p>
            </footer>
        </div>
    </div>
</div>
<script src="../static/js/jquery-3.5.1.min.js" th:src="@{/js/jquery-3.5.1.min.js}"></script>
<script>
    $(function () {
        sendAjax("/teacher/api/notice", "get", {}, function (res) {
            $.each(res.data, function (i, notice) {
                var card = $("#notice-card").clone();
                var levelinfo = notice.level === "1" ? "紧急" : notice.level === "2" ? "重要" : "普通";
                var color = notice.level === "3" ? "color: black" : notice.level === "2" ? "color: #ff6600" : "color: red";
                card.find("#level").text(levelinfo);
                card.find("#level").attr("style", color);
                card.find("#noticeinfo").text(notice.noticeinfo);
                card.appendTo("#notice-datas");
            });
            $("#notice-card:first").remove();
        }, "")
    });
</script>
<script src="../static/js/popper.min.js" th:src="@{/js/popper.min.js}"></script>
<script src="../static/js/bootstrap.min.js" th:src="@{/js/bootstrap.min.js}"></script>
<script src="../static/js/jquery.slimscroll.min.js" th:src="@{/js/jquery.slimscroll.min.js}"></script>
<script src="../static/js/script.js" th:src="@{/js/script.js}"></script>

</body>
</html>
